<!doctype html>
<html class="no-js" lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>HappyHub</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/png" th:href="@{/assets/images/icon/favicon.ico}">
    <link rel="stylesheet" th:href="@{/assets/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/themify-icons.css}">
    <link rel="stylesheet" th:href="@{/assets/css/metisMenu.css}">
    <link rel="stylesheet" th:href="@{/assets/css/owl.carousel.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/slicknav.min.css}">
    <!-- amchart css -->
    <ink rel="stylesheet" th:href="@{/assets/css/export.css}" type="text/css" media="all" />
    <!-- others css -->
    <link rel="stylesheet" th:href="@{/assets/css/typography.css}">
    <link rel="stylesheet" th:href="@{/assets/css/default-css.css}">
    <link rel="stylesheet" th:href="@{/assets/css/styles.css}">
    <link rel="stylesheet" th:href="@{/assets/css/responsive.css}">
    <!-- modernizr css -->
    <script th:src="@{/assets/js/vendor/modernizr-2.8.3.min.js}"></script>
    <script>
        function submitFormWithCaptcha() {
            // 直接生成一个验证码对象
            var captcha = new TencentCaptcha('2046758645', function (res) {
                console.log(res)
                // res（未通过验证）= {ret: 1, ticket: null}
                // res（验证成功） = {ret: 0, ticket: "String", randstr: "String"}
                if (res.ret === 0) {
                    console.log("get form")
                    var form = document.getElementById('form1');
                    console.log("get ticket")
                    var ticketInput = document.getElementById("ticket");
                    console.log("get rnadstr")
                    var randstrInput = document.getElementById("randStr");
                    console.log(res.ticket)
                    ticketInput.value = res.ticket;
                    console.log("input randstr")
                    randstrInput.value = res.randstr;
                    console.log("submit")
                    form.submit();
                }
                else
                {
                    alert("验证失败");
                }
            });
            // 显示验证码
            captcha.show();
        }
    </script>
</head>

<body>
    <!--[if lt IE 8]>
            <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a th:href="@{http://browsehappy.com/}">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
    <!-- preloader area start -->
    <div id="preloader">
        <div class="loader"></div>
    </div>
    <!-- preloader area end -->
    <!-- login area start -->
    <div class="login-area">
        <div class="container">
            <div class="login-box ptb--100">
                <form id="form1" class="form" th:action="@{/admin/login}" method="post">
                    <div class="login-form-head">
                        <h4>登录</h4>
                        <p>Hello , 登录账号进入快乐星球</p>
                    </div>
                    <div class="login-form-body">
                        <div class="form-gp">
                            <label for="exampleInputName1" >用户名</label>
                            <input type="text" id="exampleInputName1" name="username">
                            <i class="ti-user"></i>
                        </div>
                        <div class="form-gp">
                            <label for="exampleInputPassword1">密码</label>
                            <input type="password" name="password" id="exampleInputPassword1">
                            <i class="ti-lock"></i>
                        </div>
                        <p style="color: #ff0000" th:if="${param.error}"
                           th:text="${session.SPRING_SECURITY_LAST_EXCEPTION.message}">
                        </p>
                        <p style="color: #ff0000" th:text="${message}">remember me</span>
                        </p>
                        <div class="row mb-4 rmber-area">
                            <div class="col-6">
                                <div class="custom-control custom-checkbox mr-sm-2">
                                    <input type="checkbox" class="custom-control-input" id="customControlAutosizing" name="remeber-me">
                                    <label class="custom-control-label" for="customControlAutosizing">Remember Me</label>
                                </div>
                            </div>
                            <div class="col-6 text-right">
                                <a th:href="@{/admin/login/tofindpassword}">忘记密码?</a>
                            </div>
                        </div>
                        <input id="ticket" name="ticket" type="hidden" value="">
                        <input id="randStr" name="randStr" type="hidden" value="">
                        <div class="submit-btn-area">
                            <button type="button" onclick='submitFormWithCaptcha()'>登录</button>
                            <!--<button id="form_submit" type="submit">提交 <i class="ti-arrow-right"></i></button>-->
                        </div>
                    </div>
                </form>
                </form>
            </div>
        </div>
    </div>
    <!-- login area end -->

    <!-- jquery latest version -->
    <script th:src="@{/assets/js/vendor/jquery-2.2.4.min.js}"></script>
    <!-- booth:tstra 4 js -->
    <script th:src="@{/assets/js/popper.min.js}"></script>
    <script th:src="@{/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/js/owl.carousel.min.js}"></script>
    <script th:src="@{/assets/js/metisMenu.min.js}"></script>
    <script th:src="@{/assets/js/jquery.slimscroll.min.js}"></script>
    <script th:src="@{/assets/js/jquery.slicknav.min.js}"></script>
    <!-- othth:ers pugins -->
    <script th:src="@{/assets/js/plugins.js}"></script>
    <script th:src="@{/assets/js/scripts.js}"></script>
    <script th:src="@{https://ssl.captcha.qq.com/TCaptcha.js}"></script>
</body>

</html>